#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>

int main(int argc, char *argv[]) {
    if (argc != 7) {
        fprintf(stderr, "Usage: %s output.dat t a b c d\n", argv[0]);
        return 1;
    }

    const char *filename = argv[1];
    int t = atoi(argv[2]);
    double a = atof(argv[3]);
    double b = atof(argv[4]);
    double c = atof(argv[5]);
    double d = atof(argv[6]);

    srand(time(NULL));
    const int num_points = 1000;
    FILE *fp = fopen(filename, "w");
    if (!fp) {
        perror("Error opening file");
        return 1;
    }

    for (int i = 0; i < num_points; ++i) {
        double x = (rand() / (RAND_MAX / 200.0)) - 100.0;
        double y;
        switch (t) {
            case 1:
                y = a * x + b;
                break;
            case 2:
                y = a * x * x + b * x + c;
                break;
            case 3:
                y = a * x * x * x + b * x * x + c * x + d;
                break;
            default:
                fprintf(stderr, "Invalid t value: %d\n", t);
                fclose(fp);
                return 1;
        }
        fprintf(fp, "%f %f\n", x, y);
    }

    fclose(fp);
    return 0;
}